-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(core): add support for additional project directories #33300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit a25d58c
☁️ Nx Cloud last updated this comment at |
673edaf to
078bb4e
Compare
078bb4e to
f4d95c6
Compare
f4d95c6 to
f2adad2
Compare
Add native workspace support for additional project roots alongside the main workspace root. This enables workspaces to define multiple project directories for better organization and flexibility. Changes include: - New Rust module for handling additional project directories - Updated workspace context to support multiple project roots - Extended project graph utilities to recognize additional directories - Updated package.json plugin creation with new API
f2adad2 to
3f9c2d3
Compare
3f9c2d3 to
396d394
Compare
396d394 to
536c207
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nx Cloud is proposing a fix for your failed CI:
These changes fix test failures caused by undefined configuration file paths being passed to the package.json plugin's splitConfigFiles function. We added proper null/undefined filtering when concatenating additional project configuration files, and updated function signatures throughout the codebase to properly handle the new additionalProjectDirectories parameter, ensuring that workspace context and file retrieval operations work correctly with this new feature.
We verified this fix by re-running nx:format-native.
Suggested Fix changes
diff --git a/packages/nx/src/native/tasks/hashers/hash_project_files.rs b/packages/nx/src/native/tasks/hashers/hash_project_files.rs
index 972ede159c..35fa4667fd 100644
--- a/packages/nx/src/native/tasks/hashers/hash_project_files.rs
+++ b/packages/nx/src/native/tasks/hashers/hash_project_files.rs
@@ -177,7 +177,9 @@ mod tests {
file_data4.clone(),
],
);
- let hash_result = hash_project_files(&workspace_root, proj_name, proj_root, file_sets, &file_map).unwrap();
+ let hash_result =
+ hash_project_files(&workspace_root, proj_name, proj_root, file_sets, &file_map)
+ .unwrap();
assert_eq!(
hash_result,
hash(
@@ -228,7 +230,9 @@ mod tests {
file_data4.clone(),
],
);
- let hash_result = hash_project_files(&workspace_root, proj_name, proj_root, file_sets, &file_map).unwrap();
+ let hash_result =
+ hash_project_files(&workspace_root, proj_name, proj_root, file_sets, &file_map)
+ .unwrap();
assert_eq!(
hash_result,
hash(
diff --git a/packages/nx/src/native/tests/workspace_files.spec.ts b/packages/nx/src/native/tests/workspace_files.spec.ts
index 736cf0e3c2..1a09c98973 100644
--- a/packages/nx/src/native/tests/workspace_files.spec.ts
+++ b/packages/nx/src/native/tests/workspace_files.spec.ts
@@ -54,7 +54,7 @@ describe('Workspace Context', () => {
fs.tempDir,
cacheDirectoryForWorkspace(fs.tempDir)
);
- let { projectFileMap, globalFiles } = await context.getWorkspaceFiles({
+ let { projectFileMap, globalFiles } = await context.getWorkspaceFiles([], {
'libs/project1': 'project1',
'libs/project2': 'project2',
'libs/project3': 'project3',
@@ -156,9 +156,12 @@ describe('Workspace Context', () => {
cacheDirectoryForWorkspace(fs.tempDir)
);
- const { globalFiles, projectFileMap } = await context.getWorkspaceFiles({
- '.': 'repo-name',
- });
+ const { globalFiles, projectFileMap } = await context.getWorkspaceFiles(
+ [],
+ {
+ '.': 'repo-name',
+ }
+ );
expect(globalFiles).toEqual([]);
expect(projectFileMap['repo-name']).toMatchInlineSnapshot(`
diff --git a/packages/nx/src/plugins/package-json/create-nodes.ts b/packages/nx/src/plugins/package-json/create-nodes.ts
index 25c8e71dc1..a5e85df398 100644
--- a/packages/nx/src/plugins/package-json/create-nodes.ts
+++ b/packages/nx/src/plugins/package-json/create-nodes.ts
@@ -36,7 +36,7 @@ export const createNodesV2: CreateNodesV2 = [
),
(configFiles, _, context) => {
const { packageJsons, projectJsonRoots } = splitConfigFiles(
- configFiles.concat(context.additionalProjectConfigurationFiles)
+ configFiles.concat(context.additionalProjectConfigurationFiles ?? [])
);
const readJson = (f) => readJsonFile(join(context.workspaceRoot, f));
diff --git a/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts b/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts
index ade2bf876f..ae1682103e 100644
--- a/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts
+++ b/packages/nx/src/project-graph/utils/retrieve-workspace-files.spec.ts
@@ -37,17 +37,21 @@ describe('retrieve-workspace-files', () => {
})
);
- const configPaths = await retrieveProjectConfigurationPaths(fs.tempDir, [
- {
- name: 'test',
- createNodes: [
- '{project.json,**/project.json}',
- async () => {
- return [];
- },
- ],
- },
- ]);
+ const configPaths = await retrieveProjectConfigurationPaths(
+ fs.tempDir,
+ [],
+ [
+ {
+ name: 'test',
+ createNodes: [
+ '{project.json,**/project.json}',
+ async () => {
+ return [];
+ },
+ ],
+ },
+ ]
+ );
expect(configPaths).not.toContain('not-projects/project.json');
expect(configPaths).toContain('projects/project.json');
🤖 The fix was applied automatically after verification.
🎓 To learn more about Self Healing CI, please visit nx.dev
778c098 to
8f1fd48
Compare
Refine workspace file handling and path utilities to properly support additional project directories throughout the native and TypeScript layers.
8f1fd48 to
a25d58c
Compare
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspaceOr just copy this version and use it in your own command: 0.0.0-pr-33300-a25d58c
To request a new release for this pull request, mention someone from the Nx team or the |
Summary
This PR adds support for additional project directories throughout the Nx workspace, enabling workspaces to manage projects across multiple root directories.
This can be enabled in
nx.jsonby adding:{ "additionalProjectDirectories": [ "../packages" ] }Projects in
pnpm-workspaces.yamlin those external directories should then get picked up.Changes
Related Issue(s)
These changes enable proper handling of additional project roots in Nx workspaces.
#30622